refactoring of equality methods