added working version of mergesort