Eli implemented the longest-sequence function