Fixed the indexoutofboundsexception