added sum, cleaned up avg calculation