diff --git a/support/bin/rtcds.in b/support/bin/rtcds.in
index 239e9dff11d68dfa3f8d7141eb746f6f8e3c9459..8595c13b101746d73b1805f6c0dd5544bd9748ea 100755
--- a/support/bin/rtcds.in
+++ b/support/bin/rtcds.in
@@ -66,6 +66,16 @@ epics_only_model() {
     contains $1 $EPICS_ONLY_MODELS && return 0 || return 1
 }
 
+# echo the systemd unit that should be used to control the model
+get_model_unit() {
+    local sys=$1
+    if epics_only_model ${sys} ; then
+	echo "rts-epics@${sys}"
+    else
+	echo "rts@${sys}.target"
+    fi
+}
+
 check_env() {
     for var in ${USER_VARS[*]} ; do
 	if [ ! "${!var}" ] ; then
@@ -154,11 +164,7 @@ check_host_sys_enabled() {
 check_host_sys_active() {
     for sys ; do
         check_unit_available ${sys}
-	if epics_only_model ${sys} ; then
-            local unit_name=rts-epics@${sys}
-        else
-            local unit_name=rts@${sys}.target
-        fi
+        local unit_name=`get_model_unit ${sys}`
 	if ! systemctl is-active $unit_name > /dev/null ; then
 	    log "System '${sys}' is not active on this system'."
 	    exit 4
@@ -169,11 +175,7 @@ check_host_sys_active() {
 check_host_sys_inactive() {
     for sys ; do
         check_unit_available ${sys}
-        if epics_only_model ${sys} ; then
-            local unit_name=rts-epics@${sys}
-        else
-            local unit_name=rts@${sys}.target
-        fi
+        local unit_name=`get_model_unit ${sys}`
 	if systemctl is-active $unit_name > /dev/null ; then
 	    log "System '$sys' is already active on this system'."
 	    exit 4
@@ -214,11 +216,9 @@ install_world() {
 start_sys() {
     for sys ; do
 	log "### starting $sys..."
-    if epics_only_model $sys ; then
-        sudo systemctl start rts-epics@${sys}
-    else
-	    sudo systemctl start rts@${sys}.target
-    fi
+    	local unit_name=`get_model_unit ${sys}`
+        sudo systemctl start $unit_name
+
 	# pause needed to avoid timing glitch when user model started immediately after IOP
 	log "... waiting for start of ${sys} to complete"
 	sleep 15
@@ -230,11 +230,8 @@ stop_sys() {
     for sys ; do
 	log "### stopping $sys..."
 	#${SCRIPTD}/kill${sys}
-    if epics_only_model $sys ; then
-        sudo systemctl stop rts-epics@${sys}
-    else
-	    sudo systemctl stop rts@${sys}.target
-    fi
+	local unit_name=`get_model_unit ${sys}`
+        sudo systemctl stop $unit_name
     done
 }