fix arrayoutofbounds error