refactor statistics code
gem update