Refactored to align more with python style guidelines.