nrepeat logic