calculation at the frontend