changed code in the onUpdate method