update function now works