converted to python3 with 2to3, should work on python2.7 as well