added some logging and error handling