fixed a bug in the insertItem function
fixed some bugs