before moving calculation to the server side