fix a bug of accessing array at index 0