Refactoring extractIPAddress to avoid addition if checks.
Applying feedback from dbevenius