Fix infinity bug