fix array boundary error