Refactoring some of the initial code