Added some functions to handle input and output arrays