refactoring
all tests pass on py2.7 and py3.4