fixed the arrayoutofboundserror