refactors code and fixes count_winner_loser error