create function using 2nd palindrome algorithm