Refactor 'valid palindrome'.