fix an infinite loop