fix logic for when $count == -1