fixed some logic about generating urls.