wip - major refactoring