code for phase 2 of the measurement study