fix out of bound of array