public Object dequeue() throws AskFromEmpty {
        if (count > 0) {
            QueueElement previous = head;
            QueueElement current = head.next();
            if (previous == searchMax()) {
                head = head.next();
                count--;
                return previous.getValue();
            } else {
                while (current != searchMax()) {
                    previous = current;
                    current = current.next();
                }
                QueueElement help = current;
                previous.connectNext(current.next());
                count--;
                return help.getValue();
            }
        } else {
            throw new AskFromEmpty("Queue is empty!");
        }
    }