```\nif (memoryData.shareOwed <= memoryData.shareOut) {\n    _repay(from, from, memoryData.partOwed);\n} else {\n    //repay as much as we can\n    uint256 partOut = totalBorrow.toBase(amountOut, false);\n    _repay(from, from, partOut);\n}\n```\n