chore(addMT): move same statements into one function

Also move declaration for variables from for loop to the top of the
function addMT.