new python3 compliant refactor