refactor to make Pokr usable as a module