working version for ValidPalindrome