It must be a trade in or a 1031 exchange. Can not be two separate transactions.