working substring function...