Updated patch to proper existence checking

Shouldn't error in browsers.