Possible fix for #1557

This fixes #1557 by removing `instanceof` in favor of `Object.toString`.