addEventListener inside anonymous function