initial refactoring pass