fixed instanceof check