Updated url to https and better error handling