refactored sender to allow easier testing