improved ip detection