fixed problems with py3 py2 compatibility