fixed wrong code placement for addDevice