refactoring python