made a 'game' function and cleaned code