Refactor URL utils