added logic to leave game function