improved string parsing