made the code look more pythonic