fix bugs in new insert helper