handle null value & fix counter