Use generator function for page click events