use count instead of length