Fixed a crash caused by out of bound error