The constant map solution is what I was originally looking for, but couldn't think how to do cleanly. The main reason why I had all of those repeated functions was because I wanted to avoid the messiness that would be passing in those queries through an HTML tag referencing a javascript function. I like this solution.