checking index range during positioning of text