refine code for internet connection status checker