added retry loop to running query