clean up the code in the main update handler.