added safe regex check