First refactoring

Refactoring for Python 3.3.2