public boolean add(String word, int edit_distance) {

		// records the previous node
		Predecessor prev = this;

		// stores current node
		TopNode node = front;

		while( node != null) {
            if (edit_distance < node.getDistance()){
			    prev = node;
			    node = node.getNext();
            } else {
                break;
            }
        }

        TopNode newNode = new TopNode(word, edit_distance);
		prev.setNext(newNode);
        newNode.setNext(node);
        this.size++;

        if(this.size > topSize) {
            prev = this;
            node = front;
            this.setNext(front.getNext());
            this.size--;
        }

		return true;
	}