fixed bug introduced when porting to py3