refactor might work (untested)