loop lenth fix