only works under python 2.7