fix bug in setting up count