untested version of update function