improve lookup method for firstTextOffset