Added alert for the case that Internet is unreachable
Slight refactoring