prevent arrayindexoutofbounds error