Refactoring, reimplemented frequency table