`query_with_input` is only called here, I would prefer if you rolled the body of that function into this one since it's not big.