refactoring (wip ter)