Same example, but this function is called from the event handler