started taking average code. only works on a single file so far