Passing an object to a global variable