rpi, added median function