DRY up query string code