Refactor quicksort3