refactor factory to use module instead of stacks