redo im_cntlines() as a class