fixed reading index from array