First step to fix PR2088. Implement routine to compute the