change calculation to client side