changed for python3, now works on python2 and 3