changed contract.assert to debug.assert