checking for validity of characters