added averaging (not optional yet)