cleanup of update function
further wore on update function