added more logic to game loop