5(1)If, before the parties were discharged, any of them has, by reason of anything done by any other party in connection with the performance of the contract, obtained a valuable benefit other than a payment of money, the court, if it considers it just to do so having regard to all the circumstances, may allow the other party to recover from the party benefited the whole or any part of the value of the benefit.