final version 3.0
added comments
added comments and checked the logic
newer version 3.0
newer version 3.0 - use degree fixed.
final version 3.0