moving lots of calculations to the server