added error checking in assignDegrees