added error handling for activity api call