fixed bugs that caused the game to crash