Is it possible to set the callback function without setting a global variable or is this the only way?