sort out error handle