fixes segment index calculation caused by javascript floaing point problem