Modified code to accurately determine when a ghost has been eaten