reorganized to be used as a submodule