made creation of the array a function.