implement function LOOP