Use q.chain with promises to optimize route queries.