Update helpers.py

Re-factored code to support Python 3