Thanks a lot . I totally forgot about recursive function . It helped me in a project.