fix median pivot method