refactor for more sane source structure