add defer before profile plot