Fnished refactoring and addressed all comments