generalised main.xc for variable No. of motors