Updated to check status code instead of looking for "ERROR" in contents