More pythonic code