add extern delc and cleanup my_mad func