improved network conection detection