function Redeem(string _chequeId, string _pin, address _sendTo) payable returns (ResultCode){
        
        
        
        
        bytes32 chequeIdHash = sha3(_chequeId);
        Cheque cheque = items[chequeIdHash];
        if (cheque.status == Status.NONE) {
            LogRedeem(chequeIdHash, ResultCode.ERROR_NOT_EXIST, 0, _sendTo);
            return ResultCode.ERROR_NOT_EXIST;
        }
        if (cheque.status == Status.USED) {
            LogRedeem(chequeIdHash, ResultCode.ERROR_USED, 0, _sendTo);
            return ResultCode.ERROR_USED;
        }
        if (msg.sender != cheque.creator) {
            if (cheque.status != Status.CREATED) {
                LogRedeem(chequeIdHash, ResultCode.ERROR_INVALID_STATUS, 0, _sendTo);
                return ResultCode.ERROR_INVALID_STATUS;
            }
            if (cheque.attempt > maxAttempt) {
                LogRedeem(chequeIdHash, ResultCode.ERROR_LOCKED, 0, _sendTo);
                return ResultCode.ERROR_LOCKED;
            }
            if (cheque.expiringPeriod > 0 && now > (cheque.createTime + cheque.expiringPeriod)) {
                LogRedeem(chequeIdHash, ResultCode.ERROR_EXPIRED, 0, _sendTo);
                return ResultCode.ERROR_EXPIRED;
            }
        }
        
        
        if (cheque.pinHash != sha3(_chequeId, _pin)) {
            cheque.attempt += 1;
            LogRedeem(chequeIdHash, ResultCode.ERROR_INVALID_STATUS, 0, _sendTo);
            return ResultCode.ERROR_INVALID_STATUS;
        }
        
        totalRedeemedCheque += 1;
        totalRedeemedValue += cheque.value;
        uint sendMount = cheque.value;
        
        cheque.status = Status.USED;
        cheque.value = 0;
        
        _sendTo.transfer(sendMount);
        LogRedeem(chequeIdHash, ResultCode.SUCCESS, sendMount, _sendTo);
        return ResultCode.SUCCESS;
    }