fixed bug that become infinite loop