Fixed the infinity loop bug of CountModule() function