solved problem by using recursive code :)