Find Longest Consecutive Substring Function