refactoring quicksort