You should put the re-occuring vars into a closure at the top of this function (even outside the click handler)