New version of mod from LB (loop fix)