adding palindrome algorithm