fixed the logic for the regex