fixed while and if statements