fixed bug in insert method