fix bugs for insert