Finished refactoring Code phase 1