check if palindrome and word count without recursivity