new method to calculate dof