Refactoring of code to increase structure