Fix indexoutofbound.