     question = Map.merge(question, %{answer: question.question_tags})
     changeset = Question.changeset(question, question_params)
 
-    case Repo.update(changeset) do
+    case update_question_and_tags(changeset) do
       {:ok, question} ->
         question = question
         |> Repo.preload(:question_tags)

    end)
  end

  # Add the answer to a question
  #
  # Returns a {:ok, tags} or {:error, changeset} tuple

          {:error, changeset}
      end
  end

  # Remove all tags from a annotation
  defp remove_tags({:error, changeset}), do: {:error, changeset}
  defp remove_tags({:ok, question}) do
    query =  from(qt in QuestionTag, where: qt.question_id == ^question.id)
    Repo.delete_all(query)

    {:ok, question}
  end
end
