updating function nearly complete