base.py refactoring