logic for match finished