Worked on averaging during opening
Fixed Bug in reduce function