added first part of refactored statistics