fixing cnt undefined issue