fix offset in substring