modularise code for ai agents