refactor quick sort