Fixed if and added while.