preliminary ans_cnt code