rewrite iplist algo