Refactored IP address comparison into one centralized function