added while loop and recursive methods