Insertion sort implementation
Bug fix