Add substr.
Speed up by saving logging.