Remove the delay and instead put looping code to continue until successful