now handling errors gracefully