Added working update function