prelimiary semi-refactor