updated regex function