fixed detection of local IP

In case of multiple IP configurations the previous version did not worked properbly
This is more or less a quick hack.