How to create a mgdraw routine