upgrading regex  & refractoring