fixing a ghost bug caused when the ghost leaves after the mode changes