changed url argument generation to be more robust