Refactoring. Try to make in pythonic.