fix index out-of-bound error
fix out-of-bound error