fixed infinte loop