implemented how to determine which player wins