improved code for counting score after the game