refactoring mostly