add rescue to regex match function