optimize error handling and scheduling