Update median calculation to work with pipeline.