Added option to sleep before retrying