consolodate string parsing into a single function.