fixed bug for the end game