Fixed null pointer exception when no connection possible