reindented, and minor pep-8 adjustments