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

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

      unless duplicate
        nerds.push nerd
        set.push element
    expression = 'vector(' + set.join(',') + ')'
    new MampfSet(expression)

class MampfSolution
  constructor: (@type, @details) ->

  equals: (otherSolution) ->
    return false unless @type == otherSolution.type
    @details.equals(otherSolution.details)

  @parse: (content) ->
    type = content['question[solution_type]']
    details = switch
      when type == 'MampfExpression' then MampfExpression.parse(content)
      when type == 'MampfMatrix' then MampfMatrix.parse(content)
      when type == 'MampfTuple' then MampfTuple.parse(content)
      when type == 'MampfSet' then MampfSet.parse(content)
    new MampfSolution(type, details)

  @fromExpression: (type, expression) ->
    details = switch
      when type == 'MampfExpression' then new MampfExpression(expression)
      when type == 'MampfMatrix' then new MampfMatrix(expression)
      when type == 'MampfTuple' then new MampfTuple(expression)
      when type == 'MampfSet' then new MampfSet(expression)
    new MampfSolution(type, details)

extractSolution = ->
  content  = $('#solution-form').serializeArray().reduce(((obj, item) ->
    obj[item.name] = item.value
    obj
  ), {})
  MampfSolution.parse(content)

compareToSolution = (solutionInput) ->
  solutionString = $('#question_nerd').val()
  type = $('#question_solution_type').val()
  solution = MampfSolution.fromExpression(type, solutionString)
  result = solutionInput.equals(solution)
  $('#question_result').val(result)
  if result
    $('#quiz_question_crosses').val($('#quiz_question_crosses').data('answer'))
