Refactoring functions about comparing.