refactoring in compare