refactored to python 3.4