code used on midterm