Moved variable declaration closer to where it is used
Fixed bug where number larger than 2 returned array of arrays