diff --git a/src/find_interaction_cluster/nt_and_community.py b/src/find_interaction_cluster/nt_and_community.py
index cb855ff0a50f41845a2abbb4a5cdc65128644965..c38f4f878d8fb7db8d6502908d0935771e3d196e 100644
--- a/src/find_interaction_cluster/nt_and_community.py
+++ b/src/find_interaction_cluster/nt_and_community.py
@@ -278,7 +278,7 @@ def create_outfiles(project: str, weight: int, global_weight: int,
 
     outfolder = f"community_enrichment/{cpnt_type}_analysis"
     if community_file != "":
-        cn = Path(outfolder).name.replace(".txt", "")
+        cn = Path(community_file).name.replace(".txt", "")
         base = ConfigGraph.output_folder / outfolder / f"custom_{cn}"
         base.mkdir(exist_ok=True, parents=True)
         outfile = base / f"{cpnt}-{cpnt_type}_stat_{test_type}.txt"