put event listener in it own function