Refactoring the sorts