Fix a bug in insertion, reform some code