(define (make-account funds)                ; FUNDS is a local state-variable

    (define (withdraw amount)               ; local procedure WITHDRAW
         (if (>= funds amount)
             (begin
                 (set! funds (- funds amount))
                 funds)
             "Insufficient funds"))

    (define (deposit amount)                ; local procedure DEPOSIT
         (set! funds (+ funds amount))
         funds)

    (define (dispatch m)                    ; local procedure DISPATCH
         (cond ((eq? m 'withdraw) withdraw)
               ((eq? m 'deposit)  deposit)
               (else (error "Unknown request -- MAKE-ACCOUNT" m))))

    dispatch)                               ; MAKE-ACCOUNT is higher-order,
                                            ; it returns procedure DISPATCH
