implemented mergesort to replace some kind of insertion sort
optimazation on