rework key value functions - simplifying regular expression and making a single function
that handles all cases