Lengths out of bounds fix