refactoring spark related functions out to 'sparkplug'