edited logic in checking ip addresses