fixed null error if queue is empty