Moved update function to a separate file