added comments & changed count logic