Fixed loop bug in require()