refactor code according to python pep