some fix on casts into formulas