code refactored for regexp, matcher moved to separate class