refactored network detection code to support all browsers