beforeselector and afterselector should be replace with const.