You should actually be able to bypass confirmModal() entirely for swap and go directly to doRequest(). Vars newTitleText, title and msg aren't needed anywhere outside of confirmModal() so those no longer need to be defined in the case of swap.