Code Refactoring.

Refactored the code and changed the formatting style.