Refactor routing code to avoid weird parameter