refactor URL parsing