edited the url code to function synchronously