Removed unsed function and surrounded call to API in a try/catch