fix outofindex exception