revamped update code.