you are missing a global $g here.