Update regex and condition check according to suggestion