"Best Practice" way to do math on a stream of data

Hi. I have a string of numbers like "1 2 3 4 5 6" (it's way more complicated than that, but this illustrates the idea) and they represent measurements. I use buffer parser to combine them into topic/value messages. In this example, the measurements are 12, 34,56. I need to divide 56/12 to get a % used.

Should I save 56 and 12 as global and use a function to add them?
Should I use join to wait for the two messages and then add them in a function like so. This seems simple and works well.

[{"id":"62936f7e337ea844","type":"function","z":"c90f4fbedf92be5c","name":"SOC Calculator","func":"total = msg.payload.PackTmAH;\nremaining = msg.payload.PackRmAH;\n\npavailable = remaining/total;\n\nmsg.topic = \"PackPAvail\"\nmsg.payload = pavailable;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1160,"y":900,"wires":[["4b33e4f0c01c6892","9b7092f354906e38"]]}]

Is there a better way I am not thinking of?