add update function and fixes