fixed infi loop