copied over percentage calc to main.js