updated formulas, grammar and implemnetation