reimplemented insertion sort