update the code to support abnormal input.