fixed if statement for valid characters.