added small fixes to formula generation