Fix loop control