fix array out of bound exception