update main calculate function