refactor statistics.rb