added retry loop until device is ready