fixes in url expansion logic