Adding logic to change device status