wip: more refactoring