fix for 'listener must be a function' error in some environments