prevent stack overflow, check attributes only when ids are equal