added code to the mid term