added function to autofix mass balance