a better way of check palindrome