refactoring for python forward compatibility