[#1790] fix Count to avoid infinite loop