fixed quicksort implementation