Fixing endless loop if dir to clear is not found