Replaced a Python 2.7 only function with 2.6 compatible code