Calc and reduce functions