updated to deal better with different URLs