Fixed bugs in insertion sort