more explicit error checking in js_hacks