error handling in dequeue