fix bugs with equation formatter