fixed missing count variable