updated quicksort algorithm