refactored module building