diff --git a/update.php b/update.php
index 3ddce89ff8d17dca1c46c297a06315959cbb0cd4..f5623e04fd3b9d95b16579c7dc8e5b71cae8b503 100644
--- a/update.php
+++ b/update.php
@@ -387,12 +387,15 @@ function update_progress_page() {
  *   the overall percent finished. The second element is a status message.
  */
 function update_do_updates() {
-  while (($update = reset($_SESSION['update_remaining'])) && timer_read('page') < 1000) {
+  while (($update = reset($_SESSION['update_remaining']))) {
     $update_finished = update_data($update['module'], $update['version']);
     if ($update_finished) {
       // Dequeue the completed update.
       unset($_SESSION['update_remaining'][key($_SESSION['update_remaining'])]);
     }
+    if (timer_read('page') > 1000) {
+      break;
+    }
   }
 
   if ($_SESSION['update_total']) {