Update calccontroller.js

separated logic into different methods