Updated formula generation