moved calculations to server side