implement end game functionality