Refactored the game and table logic