handle optional arguments to addListener correctly