Implemented working version of game loop