rewrote quick sort