beginning rewrite of counting