Almost finished refactoring
Made refactoring