moved main gameloop from main