Fix warning: array subscvript is above array bounds