added quickselect; refacored a bit