further modularisation of code