refactored the game logic and tried to convert all javascriopt into jquery