diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm
index 0a3b8abd8180..c4fa6c7a6185 100644
--- a/code/modules/reagents/chemistry/machinery/chem_master.dm
+++ b/code/modules/reagents/chemistry/machinery/chem_master.dm
@@ -355,7 +355,8 @@ GLOBAL_LIST_INIT(chem_master_containers, list(
 		return TRUE
 
 	if(action == "selectContainer")
-		var/obj/item/reagent_containers/target = locate(params["ref"])
+		var/target_ref = params["ref"]
+		var/obj/item/reagent_containers/target = locate(target_ref)
 
 		//is this even a valid type path
 		if(!ispath(target))
@@ -364,15 +365,14 @@ GLOBAL_LIST_INIT(chem_master_containers, list(
 		//are we printing a valid container
 		var/container_found = FALSE
 		for(var/category in printable_containers)
-			for(var/obj/item/reagent_containers/container as anything in printable_containers[category])
-				if(target == container)
-					container_found = TRUE
-					break
+			if(target in printable_containers[category])
+				container_found = TRUE
+				break
 		if(!container_found)
 			return FALSE
 
 		//set the container
-		selected_container = target
+		selected_container = target_ref
 		return TRUE
 
 	if(action == "create")