refactoring python view