substring done, non recursive