added end of game functionality