Make code more pythonic (3)