implemented the end game win and lose