fixed average  so that it would correctly work when you use it on more than one
file