Updated chemical formula validation