Fixed Substring implementation