implement localhost autodetection