public void set(int key, int value) {
        // change value for existing key
        if(map.containsKey(key)) {
            DataNode node = map.get(key);
            node.val = value;
            // maintain node order in the list
            moveNodeToFirst(node);
        } else {
            DataNode node = new DataNode(key, value);
            map.put(key, node);
            // need to throw old value
            if(has == capacity) {
                map.remove(last.key);
                if(last.pre != null) { // last != null cause capacity > 0
                    last.pre.next = null;
                    last = last.pre;
                } else {
                    last = node;
                }
            } else has++;
            
            if(first != null) { // bug, forgot this = =|||
                node.next = first;
                first.pre = node;
            }
            first = node;
            if(last == null) last = node;
        }
    }