simple python refactoring