From http://stackoverflow.com/questions/111102/how-do-javascript-closures-work