add game ends and fix bug