Fix arrayindexoutofboundsexception