Updated IP address check logic