Made the code a little bit more pythonic.