fix offset one bug