diff --git a/scripts/sid b/scripts/sid
index bf3404f..cb7aa0b 100644
--- a/scripts/sid
+++ b/scripts/sid
@@ -72,6 +72,28 @@ Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
 	x_feign_install dpkg
 }
 
+some_helper_fun() {
+	returnCode='0'
+
+	info UNPACKBASE "Unpacking the base system..."
+
+	smallyes '' |
+		(in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages.  This will be re-attempted up to five times." "" \
+		dpkg --status-fd 8 --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 || echo EXITCODE $?) |
+		dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING || \
+		returnCode='1'
+
+	info CONFBASE "Configuring the base system..."
+
+	smallyes '' |
+		(in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages.  This will be re-attempted up to five times." "" \
+		dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 || echo EXITCODE $?) |
+		dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING || \
+		returnCode='1'
+
+	return "${returnCode}"
+}
+
 second_stage_install () {
 	setup_devices
 
@@ -184,17 +206,7 @@ echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/
 		done_predeps="$done_predeps $predep"
 	done
 
-	smallyes '' |
-		(repeatn 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages.  This will be re-attempted up to five times." "" \
-		dpkg --status-fd 8 --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 || echo EXITCODE $?) |
-		dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING
-
-	info CONFBASE "Configuring the base system..."
-
-	smallyes '' |
-		(repeatn 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages.  This will be re-attempted up to five times." "" \
-		dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 || echo EXITCODE $?) |
-		dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING
+	repeatn 5 some_helper_fun
 
 	mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
 	rm -f "$TARGET/usr/sbin/policy-rc.d"
