Move updating function into script