change code to use beans for modularisation