fix bad loop