use URL methods, adapt to coding style, include safety check