more pythonic code