added simpler and more clever approach using regexes