working version for is valid word