read_by_index function