Why not to write it in a much simplier way? Like this:
function bar(n) {
// still has dependency on q, r, s
}
foo(..., bar); function bar(n) {
// still has dependency on q, r, s
}
foo(..., bar);