put url handling code together
neaten by creating a pointer at first

rather than casting it later