added error handling/logging