Fixed substring function