Refactor URL handling to use library call