cleaner and safer way to retrieve IP address