fixed a scoping problem in modules gen