refined in/out handling