Fixed insertion errors where insertion index is wrong