redesign the code(pep8) and add python3 support