refactoring a lot, wip