updated code for py3