refactored sorter to separate class;
refactored generator to separate class;