Adding some simple checks before deleting a directory