Refactor Quicksort algorithm