polished update function