Made code more python-y per mano3ms recommendation.