Refactoring method equals