Redo the work such that outputs are stored in arrays