filter by interval refactoring