try to speed up the new segment mean code from last change a  little