refactored twtt.py