   $(document).on 'click', '#interpretExpression', ->
     cleanSolutionBox()
     try
-      expression = extractSolution()
+      inputSolution = extractSolution()
     catch err
-      expression = 'Syntax Error'
-    if expression == 'Syntax Error'
-      $('#solution-tex').empty().append(expression)
+      inputSolution = 'Syntax Error'
+    if inputSolution == 'Syntax Error'
+      $('#solution-tex').empty().append(inputSolution)
       $('#solution_input_tex').val('')
-      $('#solution_input_error').val(expression)
+      $('#solution_input_error').val(inputSolution)
     else
-      latex = expression.tex
+      latex = inputSolution.details.tex
       $('#solution_input_error').val('')
       $('#solution_input_tex').val(latex)
       $('#solution-tex').empty().append('$$' + latex + '$$')

      unless duplicate
        nerds.push nerd
        set.push element
    statement = 'vector(' + set.join(',') + ')'
    nerd = nerdamer(statement)
    texRaw = nerd.toTeX()
    tex = '\\{' + texRaw.substr(1, texRaw.length - 2) + '\\}'
    result =
      nerd: nerd
      tex: tex
      statement: statement
    return result

compareToSolution = (expression) ->
  solutionString = $('#question_nerd').val()
  solutionNerd = nerdamer(solutionString)
  expressionNerd = nerdamer(expression)
  type = $('#question_solution_type').val()
  if type == 'MampfExpression'
    result = solutionNerd.expand().eq(expressionNerd.expand())
  else if type == 'MampfMatrix'
    rowCount = parseInt($('#question_row_count').val())
    columnCount = parseInt($('#question_column_count').val())
    if parseInt($('#matrixRowCount').data('count')) != rowCount ||
    parseInt($('#matrixColumnCount').data('count')) != columnCount
      result = false
    else
      result = true
      for i in [1..rowCount]
        for j in [1..columnCount]
          c1 = nerdamer('matget(' + solutionString + ',' + (i-1) + ',' + (j-1) + ')')
          c2 = nerdamer('matget(' + expression + ',' + (i-1) + ',' + (j-1) + ')')
          result = false unless c1.expand().eq(c2.expand())
  else if type == 'MampfTuple'
    size = parseInt(nerdamer('size(' + solutionString + ')'))
    if parseInt(nerdamer('size(' + expression + ')')) != size
      result = false
    else
      result = true
      for i in [1..size]
        c1 = nerdamer('vecget(' + solutionString + ',' + (i-1) + ')')
        c2 = nerdamer('vecget(' + expression + ',' + (i-1) + ')')
        result = false unless c1.expand().eq(c2.expand())
  else if type == 'MampfSet'
    size = parseInt(nerdamer('size(' + solutionString + ')'))
    console.log size
    console.log parseInt(nerdamer('size(' + expression + ')'))
    if size != parseInt(nerdamer('size(' + expression + ')'))
      result = false
    else
      result = true
      if size > 0
        for i in [1..size]
          c1 = nerdamer('vecget(' + solutionString + ',' + (i-1) + ')')
          found = false
          for j in [1..size]
            c2 = nerdamer('vecget(' + expression + ',' + (j-1) + ')')
            found = true if c1.expand().eq(c2.expand())
          result = false unless found
  $('#question_result').val(result)
  if result
    $('#quiz_question_crosses').val($('#quiz_question_crosses').data('answer'))

  $('#solution-error').empty()
  $('#solution-box').hide()
  try
    solutionInput = extractSolution()
  catch err
    solutionInput = 'Syntax Error'
  if solutionInput == 'Syntax Error'
    $('#solution_input_tex').val('')
    $('#solution_input_error').val(solutionInput)
    $('#solution_content_nerd').val('')
    $('#question_result').val(false)
  else
    latex = solutionInput.details.tex
    $('#solution_input_tex').val(latex)
    $('#question_quiz_solution_input').val('$' + latex + '$')
    $('#solution_input_error').val('')
    $('#solution_content_nerd').val(solutionInput.details.expression)
    if $('#question_result').length > 0
      compareToSolution(solutionInput)
  $('#submit-solution').hide()
  return

