Fixed counting demo to use boolean expression