bug fix for insert.cpp