movingn game logic into seperate function