Code Review

Compare your solutions

    #| BEGIN (Write your solution here) |#
; My code
(define (make-account balance db-pwd)
    (define error-times 0)
    (define (call-the-cops) (error "Cops called"))
    (define (login-fail)
        (set! error-times (+ error-times 1))
        (if (> error-times 7)
            (call-the-cops)
            ""
        )
    )
    (define (withdraw amount)
        (if (>= balance amount)
            (begin (set! balance (- balance amount)) balance)
            "Insufficient funds"
        )
    )
    (define (deposit amount)
        (set! balance (+ balance amount)) balance
    )
    (define (dispatch pwd m)
        (cond
            ((not (eq? pwd db-pwd)) (lambda (arg) (login-fail) "Wrong password"))
            ((eq? m 'withdraw) (set! error-times 0) withdraw)
            ((eq? m 'deposit) (set! error-times 0) deposit)
            (else (error "Unknown request: MAKE-ACCOUNT" m))
        )
    )
    dispatch
)
#| END |#