Sorry for taking so long to reply...I have been without a working pc for a long time and I am just going thru my emails.
The temp() is executed when IC2 receives a message per the following line:
Wire.onReceive(temp);
This allows the mega to stop the loop and process the data being received...In the example I actually was processing it with the lopp