Fix infinity loop