Moved update handler code into its own file