remove defer and use boost scope exit