fixed findDegree method