fixed count overflow bug