Factor out common part of routes