Added solution for countChange function