fix infinte loop