improving script to select network location