Working IF and WHILE statements