complete the remove file from failed folder logic
refactor