Applied DRY principle.
code refactored.
functions updated.
Intdentation Improved.