completed modular version