While loops, if and rand - fixed