Use instanceof instead of detectInstance

@wycats changed to use instanceof