refactor in/out