refactor `tail`