 
   encode: (input) ->
     bytes = (x) ->
+      output = []
       if typeof x is 'string'
-        x.split('').map (c) =>
+        output = x.split('').map (c) =>
           return c.charCodeAt(0)
 
       else if Array.isArray(x)
-        output = []
         input.forEach (part) ->
           output.push bytes(part)
 
-        return output
+      return output
 
     return new Buffer([0x1b].concat bytes(input))
 

  # Cursor actions
  up: (num) ->
    if typeof num is 'number'
      @set '[' +num+ 'A'
    return @

  down: (num) ->
    if typeof num is 'number'
      @set '[' +num+ 'B'
    return @

  right: (num) ->
    if typeof num is 'number'
      @set '[' +num+ 'C'
    return @

  left: (num) ->
    if typeof num is 'number'
      @set '[' +num+ 'D'
    return @

  pos: (x, y) ->
    if typeof x is 'number' and typeof y is 'number'
      @set '[' + x + ';' + y + 'H'
    return @

  fillLine: ->

    return @

  color: (fore, back) ->
    @set '[' + (if fore? and back? then (@codes.colors[fore].fore + ';' + @codes.colors[back].back) else 0) + 'm'
    return @

  format: (code) ->
    code = @codes.format[code]
    @set('[' + (if code? then code else 0) + 'm')
    return @

  erase: ->
