midterm code