trying to make output matrix global so it can be input in next iteration. not sure that replicate will actually work for this...
replicate still not working for competitions