Selling a building that is an endowment and with that money buying another one that is more profitable

Question
Is it permissible to sell a building that is an endowment for a profit, then to purchase another building in a more suitable location, and then to make that building an endowment in place of the first one?
Answer

The established position among the scholars is that an endowment is not to be sold unless it ceases to be profitable. In such a case it can be sold and something similar be bought in its place. If, however, it remains profitable, then it is not permissible to sell it unless the profit is negligible, such as a place that is rented out for a very small amount, or a piece of land that produces very little in contrast to its value. In such cases, the small profit should be overlooked, and the endowment be replaced with one more profitable.