Better server querying

Removes code repeat.