refactoring, mostly