Making some refactoring changes as suggested
Merged changes and also added some feedback in