extract method for equality check (was breaking DRY rule, implemented
twice)