Fixing a bug in validity for chemical formula.