fix outofbound error