refactoring: move reusable building blocks to common.py