count logic bug fixed