modify some code for error case