updated ip lookup logic