implemented the isEqual method