rename some variables
fixed a typo in function Count()