use substr to trim string