Correct logic for py3