refactor code for upcoming changes to tail.go