error handling and log messages