Updated to solve problem with input / output arrays