Correctected R code for waiting for pending upload