Refactored longest_palindrome.rs