Refactoring mostly