fixing empty queue error and reset