fixed counting error