refactoring and flake8