diff --git a/uuid.core.inc b/uuid.core.inc
index cc70a2e..830aabe 100644
--- a/uuid.core.inc
+++ b/uuid.core.inc
@@ -99,10 +99,11 @@ function user_entity_uuid_presave(&$entity, $entity_type) {
    * users who's accounts were migrated from Drupal 6 and who haven't updated
    * their password.
    */
-  if (isset($entity->pass)
-    && (!('$S$D' == substr($entity->pass, 0, 4)) || preg_match('/^[a-f0-9]{32}$/', $entity->pass))) {
-    // Ensure user's password is hashed.
-    $entity->pass = user_hash_password($entity->pass);
+  if (isset($entity->pass) && !preg_match('/^[a-f0-9]{32}$/', $entity->pass)) {
+    require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
+    if (user_needs_new_hash($entity)) {
+      $entity->pass = user_hash_password($entity->pass);
+    }
   }
 
   if (empty($entity->picture)) {
