partially refactored averages class