Implemented countChange function