modified SP to accept length of trim = 0 and removed con2 as it doesn't apply