code for midterm