transform the core of jgrep into a reusable module