substring function corrected
index of and last index of functions corrected