     compute(remaining_input, [out | stack], dict)
   end
 
-  def compute([ "?" | remaining_input], stack, dict) do
-    compute([ "if" | remaining_input], stack, dict)
-  end
-
-  # If-Then-Else
+  # def compute([ "?" | remaining_input], stack, dict) do
+  #   compute([ "if" | remaining_input], stack, dict)
+  # end
+
+  # If-Else-Then
   # Note that this is a prefix function!
-  # Usage: test_val is on top of stack. "if <then-value> <else-value>"
-  # puts then-value on top of stack if test_val != 0, else-value if test_val == 0.
-  # There are currently no blocks (like do-end style blocks) so you may
-  # have to define functions to implement branching behavior.
-  def compute([ "if", th, el | remaining_input], [x | stack], dict) do
+  # Usage: test_val is on top of stack. "if <then-clause> else <else-clause> then"
+  # puts then-clause on top of instruction stack if test_val != 0, else-clause if test_val == 0.
+  def compute([ "if" | remaining_input], [x | stack], dict) do
+    {if_clause, ["else" | remaining_input]} = Enum.split_while(remaining_input, fn(ins) -> ins != "else" end)
+    {else_clause, ["then" | remaining_input]} = Enum.split_while(remaining_input, fn(ins) -> ins != "then" end)
     if x != 0 do
-      compute([th | remaining_input], stack, dict)
+      compute(if_clause ++ remaining_input, stack, dict)
     else
-      compute([el | remaining_input], stack, dict)
+      compute(else_clause ++ remaining_input, stack, dict)
     end
   end
 

  end

  # Comments
  def compute([ "#" | remaining_input ], stack, dict) do
    {_, [";" | remainder]} = Enum.split_while(remaining_input, fn(ins) -> ins != ";" end)
    compute(remainder, stack, dict)
  end


  # Prints the literal value of the top of the stack, popping it
  def compute([ "." | remaining_input], [x | stack], dict) do
    IO.puts x
    compute(remaining_input, stack, dict)
  end

  # Emits a carriage return
  def compute([ "cr" | remaining_input], stack, dict) do
    IO.puts ""
    compute(remaining_input, stack, dict)
  end

