implemented suggestions in comments, mostly pep8