bug fixed: infinite loop