changed second segment's local id to -2 and fixed code to respect it'