update calculator to use a more functional approach

this gives a clearer picture of what's going on