coarsened the recursion by using insertion sort