Making code more pythonic.