add instanceOf checks in equals