proc with non-local variables