diff --git gigya.admin.inc gigya.admin.inc
index 69f8156..fcbec00 100644
--- gigya.admin.inc
+++ gigya.admin.inc
@@ -388,7 +388,7 @@ function gigya_admin_form($form, &$form_state) {
     // Build a list of core Profile registration form fields.
     if (module_exists('profile')) {
       $profile_registration_fields = _profile_get_fields(NULL, TRUE);
-      while($profile_registration_field = db_fetch_object($profile_registration_fields)) {
+      foreach($profile_registration_fields as $profile_registration_field) {
         $form['bio_mapping']['gigya_map_' . $profile_registration_field->name] = array(
           '#type' => 'textfield',
           '#title' => check_plain($profile_registration_field->title),
diff --git gigya.module gigya.module
index f3289a4..2e7d2c7 100644
--- gigya.module
+++ gigya.module
@@ -1463,7 +1463,7 @@ class GigyaUser {
 
         foreach ($profile_categories as $category) {
           $result = _profile_get_fields($category['name']);
-          while ($field = db_fetch_object($result)) {
+          foreach ($result as $field) {
             // Only attempt to set this variable if we've mapped it and
             // it isn't already set elsewhere.
             if (variable_get('gigya_profile_' . $field->name, '') != '0' && !isset($edit[$field->name])) {
