checks for internet, works in browser and node