--- masquerade.module.cvs20061030_05	2006-10-30 04:05:18.000000000 -0500
+++ masquerade.module	2006-10-30 15:04:26.000000000 -0500
@@ -39,10 +39,11 @@ function masquerade_menu($may_cache) {
       'access' => !$GLOBALS['masquerading'] && (user_access('masquerade as user') || user_access('masquerade as admin')),
       'type' => MENU_NORMAL_ITEM);
 
+    $masquerading = db_result(db_query("SELECT uid_from FROM {masquerade} WHERE sid = '%s' AND uid_as = %d", session_id(), $user->uid));
     $items[] = array('path' => 'masquerade/unswitch', 
       'title' => t('switch back'),
       'callback' => 'masquerade_switch_back',
-      'access' => $GLOBALS['masquerading'],
+      'access' => $masquerading,
       'type' => MENU_NORMAL_ITEM);
 
     $items[] = array('path' => 'masquerade/autocomplete',
