fixed #12 and optimized for flake8