insert position calculation