refactored equals