Better error checking when copying