URL handling code refactored to a module