fixed quick sort implementation