logic for game finished