rm some assert statement to stop the code crashing, and add some error handle logic