Made script more pythonic.