diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java
index c8a57a86663298f424aca7171125ec8244b8b38a..e89bcdf5a497fb29075b6f33ff5eafd3d3173c0c 100644
--- a/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java
+++ b/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java
@@ -123,16 +123,16 @@ public class CreateHierarchyCommand extends ModelCommand {
 			alias.setCompartment(null);
 			alias.setTransparencyLevel("");
 		}
-		for (BioEntity bioEntity: getModel().getBioEntities()) {
+		for (BioEntity bioEntity : getModel().getBioEntities()) {
 			bioEntity.setVisibilityLevel("0");
 		}
-		Set<PathwayCompartment> toRemove = new HashSet<>();
+		Set<Compartment> toRemove = new HashSet<>();
 		for (Compartment alias : getModel().getCompartments()) {
 			if (alias instanceof PathwayCompartment) {
-				toRemove.add((PathwayCompartment) alias);
+				toRemove.add(alias);
 			}
 		}
-		for (PathwayCompartment alias : toRemove) {
+		for (Compartment alias : toRemove) {
 			getModel().removeElement(alias);
 		}
 	}