fix out of array bug