refactoring the parts of less