fixed various syntax errors in average process
changed average update to after result save
average caluculation tested and working