fix ip detect function (again)