     @_showNextLine (->)
 
   _executeNextLineGettingOutput: ->
-    if @next_line == 1
-      @next_line = 2
-      return "1\n"
-    else if @next_line == 2
-      @next_line = 3
-      return "2\n"
-    else if @next_line == 3
+    next_line = @program.map[@next_line].map.next
+    output    = @program.map[@next_line].map.output
+    if next_line == 'finish'
       @state = 'WAITING'
       @next_line = null
-      return "3\n"
+    else
+      @next_line = next_line
+    return output
 
   clickRun: ->
     return unless @state == 'WAITING'

    @setTimeout scrollConsole, 1 # timeout to avoid weird layout bug

  _codeWithLineNums: ->
    lines = $one('textarea.code-editor').textContent.split("\n")
    new_lines = ["<br>\n"] # blank line at beginning
    line_num = 1
    for line in lines
      new_lines.push "<div class='num _#{line_num}'>#{line_num}</div> " +
        "<div class='code _#{line_num}'>#{escapeHTML(line)}</div>"
      line_num += 1
    new_lines.join("\n") + "<br>\n" # blank line at end

  clickPower: ->
    if @state == 'OFF'
      @state = 'WAITING'
      @next_line = 1
      $one('div.machine .before-cursor').textContent = ''
      $one('div.machine .instructions .content').innerHTML =
        @_codeWithLineNums()

  MILLIS_FOR_SCROLLED_INSTRUCTIONS_TENTH = 5

  constructor: (line_height, setTimeout, code_mirror) ->
    @program = null
    @state = 'OFF'
    @next_line = null
    @line_height = line_height
