Refactoring code. Adding ability to retry sending data to Sparkngin