Fix bad loop