Modularize the update function.