diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c
index 2fecb32e12..db53fae7df 100644
--- a/src/mod/applications/mod_dptools/mod_dptools.c
+++ b/src/mod/applications/mod_dptools/mod_dptools.c
@@ -1433,7 +1433,6 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
 	switch_event_create(&params, SWITCH_EVENT_MESSAGE);
 	switch_assert(params);
 	switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "as_channel", "true");
-	
 
 	if (switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, params) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", user, domain);
@@ -1464,10 +1463,6 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
 		}
 	}
 
- done:
-
-	switch_event_destroy(&params);
-
 	if (dest) {
 		const char *var;
 		char *d_dest = NULL;
@@ -1530,10 +1525,14 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
 		}
 	}
 
+ done:
+
 	if (xml) {
 		switch_xml_free(xml);
 	}
 	
+	switch_event_destroy(&params);
+
 	switch_safe_free(user);
 
 	return cause;