added the counter algorithm in, but it feels like it's not right or finished. We'll have to see.