moved calculation to backend