pim_sum median condition now calculated, not mean

this needs to be tested