refactor happygrep.sh code