factoring out string utility functions