js code to create event listener wrapper