Deductions & credits

Just to be clear, I want to do a cash-out refinance on homeA. The cash-out amount would be equal to or lesser than the principal of the loan on homeB. I will then use the cash-out to fully pay and close the loan on homeB. This would effectively result in a loan on homeA with the principal being originalHomeA-principal + originalHomeB-principal.

 

So the interest on the new loan on homeA would then be fully deductible because the use of the money has remained the same? The same being "a loan against the homeA"?