slight refactoring and pep8