diff --git a/data/test.mod b/data/test.mod
index bbb8ce41cf9ba422e9513a4387819ef957d1ba4c..4fddb95eedcbdf297665b4f72776ae8898af9bea 100644
--- a/data/test.mod
+++ b/data/test.mod
@@ -59,10 +59,28 @@ PROCEDURE trates(v) {
     minf=1-1/(1+exp((v-vhalfm)/km))
     hinf=1/(1+exp((v-vhalfh)/kh))
 
+    if(minf<0) {
+        foo1()
+    }
+    else if (hinf<0) {
+        foo2()
+    }
+    else {
+        foo3()
+    }
+
+    if(minf>=m) {
+        foo3()
+    }
+
     mtau = 0.6
     htau = 1500
 }
 
+PROCEDURE foo1() {}
+PROCEDURE foo2() {}
+PROCEDURE foo3() {}
+
 : the 'states' in the definition is giving the derivative a name
 : this name is then used in the SOLVE statement above
 : should states be a procedure with special declaration syntax (takes no arguments by default)?
diff --git a/modcc/cprinter.cpp b/modcc/cprinter.cpp
index 3d4b01d4a4fe608da52f83a26699a5e206604edf..a34a8c5432d9ffa99c836cf785892aed790a68d2 100644
--- a/modcc/cprinter.cpp
+++ b/modcc/cprinter.cpp
@@ -473,7 +473,9 @@ void CPrinter::visit(BlockExpression *e) {
         // these all must be handled
         text_.add_gutter();
         stmt->accept(this);
-        text_.end_line(";");
+        if (not stmt->is_if()) {
+            text_.end_line(";");
+        }
     }
 }
 
@@ -487,8 +489,24 @@ void CPrinter::visit(IfExpression *e) {
     increase_indentation();
     e->true_branch()->accept(this);
     decrease_indentation();
-    text_.add_gutter();
-    text_ << "}";
+    text_.add_line("}");
+    // check if there is a false-branch, i.e. if
+    // there is an "else" branch to print
+    if (auto fb = e->false_branch()) {
+        text_.add_gutter() << "else ";
+        // use recursion for "else if"
+        if (fb->is_if()) {
+            fb->accept(this);
+        }
+        // otherwise print the "else" block
+        else {
+            text_ << "{\n";
+            increase_indentation();
+            fb->accept(this);
+            decrease_indentation();
+            text_.add_line("}");
+        }
+    }
 }
 
 // NOTE: net_receive() is classified as a ProcedureExpression
diff --git a/modcc/cudaprinter.cpp b/modcc/cudaprinter.cpp
index 175781a203df3351ccc62051813c24e0a1e8262b..9d60a3f6630528ce4bdc52d4503ce05316a14c05 100644
--- a/modcc/cudaprinter.cpp
+++ b/modcc/cudaprinter.cpp
@@ -614,7 +614,9 @@ void CUDAPrinter::visit(BlockExpression *e) {
         // these all must be handled
         text_.add_gutter();
         stmt->accept(this);
-        text_.end_line(";");
+        if (not stmt->is_if()) {
+            text_.end_line(";");
+        }
     }
 }
 
@@ -628,8 +630,24 @@ void CUDAPrinter::visit(IfExpression *e) {
     increase_indentation();
     e->true_branch()->accept(this);
     decrease_indentation();
-    text_.add_gutter();
-    text_ << "}";
+    text_.add_line("}");
+    // check if there is a false-branch, i.e. if
+    // there is an "else" branch to print
+    if (auto fb = e->false_branch()) {
+        text_.add_gutter() << "else ";
+        // use recursion for "else if"
+        if (fb->is_if()) {
+            fb->accept(this);
+        }
+        // otherwise print the "else" block
+        else {
+            text_ << "{\n";
+            increase_indentation();
+            fb->accept(this);
+            decrease_indentation();
+            text_.add_line("}");
+        }
+    }
 }
 
 void CUDAPrinter::print_procedure_prototype(ProcedureExpression *e) {