added error handling to globals.js