cleaning up the code to use a common registerGlobalObject()