refactored game loop, and added restarting game