Added a bit of error handling
Output a JS array  for globals.