Moved logging codeblock above URL handling