Put the if-else in the inOut helper function in the 'definition' portion of the function rather than the inner loop