Refinement of weighted.median