fixed reading array length