function added that checks if device is online