Moving the js into a modular patter, it is better to avoid globals or annoymous functions