Moved update function to separate file