refactored event binding