Removed dependency on $GLOBALS