modified equal function