Check size before taking substr