rewrite quicksort, more elegant