Fixed gameloop - infinite loop bug