refactor in prep for code gen