refactor equality comparison