               # If the a block is embedded
               # directly in another block, we should
               # insert a socket around it automatically.
-              if stack?[stack.length - 1]?.type is 'block'
+              if stack[stack.length - 1]?.type is 'block'
                 # Push the socket to the autoinsertedStack,
                 # so that we know to close it later.
                 autoinsertStack.push mark.token.block

              
              # If we need to close an autoinserted socket,
              # close it.
              if mark.token.block is autoinsertStack?[autoinsertStack.length - 1]
                autoinsertStack.pop()
                head = head.append stack.pop().end

            when 'socketEnd'
              unless mark.token.socket is stack[stack.length - 1]
                throw new Error 'Improper parser: socket ended too early.'
              
              # Update stack
              stack.pop()

              head = head.append mark.token

          lastIndex = mark.location.column
      

            # its corresponding Start token; if it is not,
            # we throw.
            when 'indentEnd'
              unless mark.token.indent is stack[stack.length - 1]
                throw new Error 'Improper parser: indent ended too early.'
              
              # Update stack and indent depth
