Replace logic to models