First (rough) implementation of the update function