1. add first_event_after and last_event_before
2. rewrite recode binary algorithm