code from reijosirila to support string (#7) (needs testing)