change valid ip logic