wrote iterative palindrome method with comment