Tiny refactor to be more pythonic. Tried to comment for clarity.