refactoring of equality validator