finished palindrome function