array function 1 complete. Needs further testing