Changed string check using instanceof to check using Object.prototype.toString instead (for browsers less than < ie9).