Added implementation of update function