refactoring set first and last after cutoff