fixed infiten loop bug