check if dir exists before deleting