handle py2 and py3 correctly