fix pep8 and improve code