refactor to include Average and move the data ownership to its own files