refactoring sender.py