refactor sorter class