refactor lead and lag