Revert code to the original. (There was a python 2 and python 3 compatibility problem but if the python 2 usage can be supposed the original code is the good solution.)