remove infinite loop bug