added a check for the existence of graveyard