added averaging