Refactored match to use regex