Added code to the MidTerm code.