wip: reorganizing functions