added a retry option for flashing