Function for the event listener created just above