Added a helper function for the update method in the api routes