Added extra security against infinite loops!