add error checking and mv callback into the anonymous func