Er, no, that's also a rather inelegant solution. Just put the code right after the spot where you change the resolution. You don't need an other function.

(And btw, if you don't want to return something, better use "void" instead of "function"...)