wip: restructuring code