modify avg calculation