wrote game end sequence code