Added error handling to the queue