add pre-grep optimization