Fixed bug where arrayOfState is undefined