modified IP search adding a threshold to improve performance