fix out of bound error