code to extract questions and answers