Made things a bit more Pythonic with generators