diff --git a/preprocMd.sh b/preprocMd.sh
index 739362e5a0b5b7b4a86b0106e54be15f3dbab22d..b4e5801c8e0f7647c27b7748e0abe397da930a3b 100755
--- a/preprocMd.sh
+++ b/preprocMd.sh
@@ -2,21 +2,22 @@
 
     # generate namelist of collaborators from topic file
     original="./topics/topic-template.md"
-    filename="./build/topic-template-build.md"
+    filename="topic-template.md"
+    build_dir="./build"
     baseurl='https://www.mat.tuhh.de'
 
     #make output copy
-    cp $original $filename
+    cp $original $build_dir/$filename
 
     #replace working group
     for wg in {aa,cm,dm,nm,st}
     do
         fullname=`wget -qO- $baseurl/forschung/$wg | grep h1 | sed -e "s/<h1>\s*\(.*\)<\/h1>.*$/\1/g" | sed -e 's/^[ \t]*//'`
-        sed -i "s;### Working Groups:\(.*\)$wg\(.*\);### Working Groups:\1\[$fullname\]($baseurl/forschung/$wg)\2;g" $filename 
+        sed -i "s;### Working Groups:\(.*\)$wg\(.*\);### Working Groups:\1\[$fullname\]($baseurl/forschung/$wg)\2;g" $build_dir/$filename 
     done
 
 
-    namelist=`grep -h -i -m 1 -r "###\s*Collaborators (MAT):" $filename | sed -e 's/^###\s*Collaborators (MAT):\s*//I' -e 's/\s*,\s*/\n/g'  | sort -u`
+    namelist=`grep -h -i -m 1 -r "###\s*Collaborators (MAT):" $build_dir/$filename | sed -e 's/^###\s*Collaborators (MAT):\s*//I' -e 's/\s*,\s*/\n/g'  | sort -u`
     for name in $namelist
     do
         # pipeline to get full name of staff-member from mat-homepage
@@ -39,12 +40,12 @@
         fi
 
         # replace name in .md file
-        sed -i "s;$name;\[$fullname\]($baseurl/home/$name);g" $filename
+        sed -i "s;$name;\[$fullname\]($baseurl/home/$name);g" $build_dir/$filename
 
         echo "# $fullname" > ./build/$name.md
 
         # append research to staffiles
-        title="## `head -n 1 $filename | sed -e "s;#\s*;\[;g" -e "s;\(.*\);\1\]($filename);g"`"
+        title="## `head -n 1 $build_dir/$filename | sed -e "s;#\s*;\[;g" -e "s;\(.*\);\1\](${filename%.md}.html);g"`"
         echo $title >> ./build/$name.md
 
     done