refactor corpus to external module