refactored averages to avoid repetition