Fixed bug with array length