Refactor to query commands and a maximum routes policy