fixed a small bug in the partition algorithm