Moved update script into function.