moving calc code to calc class