Slightly better while loop