fixing update function