refactoring lehmer