Shouldn't you check for the error first, and *then* defer the removal if there were no errors?