added error handling for dynamoDB writes