update function for click event