cleaning up update function