Changed the timing and the placement of code in MASTER