Added code to check active network availability