Refactor postfix formula to work with arbitrary parameters