got it working in a more modular way