fix bags with logging and error handling