add median and avgmedian read functions, untested however