Fixed performance bug in LOOP