I decide whehter to add 1 or add 2 based on the value in index end+1

maybe need more refactor