for loop and if else faily fixed. added while loop