modified draw code