WIP: build
WIP: reorganize code