resolved index out of bounds issue