fixed bug where averaging data did not work correctly