move url mapping logic to separate function