fix ip function