Fix loop setup